//
//  BaseTabBarViewController.m
//  Items
//
//  Created by admin on 15/11/10.
//  Copyright (c) 2015年 admin. All rights reserved.
//

#import "BaseTabBarViewController.h"
#import "MainViewController.h"
#import "MineViewController.h"
//
#import "BenefitsViewController.h"
//
#import "RenWuViewController.h"
#import "MallViewController.h"
@interface BaseTabBarViewController ()<UITabBarControllerDelegate>

@end

@implementation BaseTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    MainViewController *mainVC = [[MainViewController alloc] init];
    [self addChildVC:mainVC  imageName:@"icon_zhu.png" title:@"首页"];

    RenWuViewController *renWuVC = [[RenWuViewController alloc] init];
    [self addChildVC:renWuVC  imageName:@"icon_qiang.png" title:@"抢任务"];
    
    MallViewController *mallVC = [[MallViewController alloc] init];
    [self addChildVC:mallVC imageName:@"icon_shangc" title:@"商城"];

    BenefitsViewController *benefitsVC = [[BenefitsViewController alloc] init];
    [self addChildVC:benefitsVC  imageName:@"icon_shou.png" title:@"看收益"];
    
    MineViewController *mineVC = [[MineViewController alloc] init];
    [self addChildVC:mineVC  imageName:@"icon_wo.png" title:@"我的"];


    
    
    
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//建立tabBar navigationBar构造器
- (void)addChildVC:(UIViewController *)childVC imageName:(NSString *)imageName title:(NSString *)title{
    
    //设置默认图标
    childVC.tabBarItem.image = [UIImage imageNamed:imageName];
    //设置导航控制器
    UINavigationController *childNVC = [[UINavigationController alloc] initWithRootViewController:childVC];
    childNVC.tabBarItem.title = title;
    self.tabBar.tintColor = kBackGroundColor;
    self.tabBar.backgroundColor = [UIColor blackColor];
    self.navigationController.navigationBar.backgroundColor = [UIColor redColor];
    
    UIView *bgView = [[UIView alloc] initWithFrame:self.tabBar.bounds];
    bgView.backgroundColor = kTabBarColor;
    [self.tabBar insertSubview:bgView atIndex:0];
    
    [self addChildViewController:childNVC];
    //childNVC.tabBarItem.imageInsets = UIEdgeInsetsMake(-2 ,0, 2, 0);
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
